package com.spa.interfaces.massagist;

import com.spa.application.command.massagist.MassagistOnlineCommand;
import com.spa.application.dto.massagist.MassagistHomeDTO;
import com.spa.application.service.massagist.MassagistHomeApplicationService;
import com.spa.infrastructure.common.ResponseMessage;
import com.spa.interfaces.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("massagist/home")
public class MassagistHomeController extends BaseController {

    @Autowired
    private MassagistHomeApplicationService messagistApplicationService;

    @PostMapping("/query/homeInfo")
    public ResponseMessage<MassagistHomeDTO> queryMassagist() {
        return responseHelper.success(messagistApplicationService.getMyHomeInfo());
    }

    @PostMapping("/online")
    public ResponseMessage online(@Validated @RequestBody MassagistOnlineCommand command) {
        return responseHelper.success(messagistApplicationService.online(command));
    }

    @PostMapping("/offline")
    public ResponseMessage offline() {
        return responseHelper.success(messagistApplicationService.offline());
    }

    @PostMapping("/refresh/lonlat")
    public ResponseMessage refresh(@Validated @RequestBody MassagistOnlineCommand command) {
        return responseHelper.success(messagistApplicationService.lonlat(command));
    }

    @PostMapping("/onetouchcall")
    public ResponseMessage<Object> touchCall() {
        messagistApplicationService.touchCall();
        return responseHelper.success();
    }

}
